home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / CollectionPrivate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  3.2 KB  |  93 lines

  1. /* Collection definitions for the use of subclass implementations only
  2.    Copyright (C) 1993,1994 Free Software Foundation, Inc.
  3.  
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: May 1993
  6.  
  7.    This file is part of the GNU Objective C Class Library.
  8.  
  9.    This library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public
  11.    License as published by the Free Software Foundation; either
  12.    version 2 of the License, or (at your option) any later version.
  13.    
  14.    This library is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.    Library General Public License for more details.
  18.  
  19.    You should have received a copy of the GNU Library General Public
  20.    License along with this library; if not, write to the Free
  21.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */ 
  23.  
  24. #ifndef __CollectionPrivate_h_INCLUDE_GNU
  25. #define __CollectionPrivate_h_INCLUDE_GNU
  26.  
  27. #include <objects/stdobjects.h>
  28. #include <objects/eltfuncs.h>
  29.  
  30. @interface Collection (ArchivingHelpers)
  31. /* These methods should never be called except in order inside 
  32.    -write: and -read: */
  33. - _writeInit: (TypedStream*)aStream;
  34. - _readInit: (TypedStream*)aStream;
  35. - _writeContents: (TypedStream*)aStream;
  36. - _readContents: (TypedStream*)aStream;
  37.  
  38. /* The Coding versions of the above */
  39. - (void) _encodeCollectionWithCoder: (Coder*) aCoder;
  40. + _newCollectionWithCoder: (Coder*) aCoder;
  41. - (void) _encodeContentsWithCoder: (Coder*)aCoder;
  42. - (void) _decodeContentsWithCoder: (Coder*)aCoder;
  43. @end
  44.  
  45.   
  46. /* To be used inside methods for getting the element comparison function.
  47.    This macro could be redefined when the comparison function is an
  48.    instance variable or is fixed.
  49.    I'm wondering if I should put _comparison_function back as an instance 
  50.    variable in Collection. */
  51. #define COMPARISON_FUNCTION [self comparisonFunction]
  52.  
  53. /* Use this for comparing elements in your implementation. */
  54. #define COMPARE_ELEMENTS(ELT1, ELT2) \
  55.   ((*COMPARISON_FUNCTION)(ELT1, ELT2))
  56.  
  57. #define ELEMENTS_EQUAL(ELT1, ELT2) \
  58.   (COMPARE_ELEMENTS(ELT1, ELT2) == 0)
  59.  
  60. #define ENCODING_IS_OBJECT(ENCODING) \
  61.   ((*(ENCODING) == _C_ID) || (*(ENCODING) == _C_CLASS))
  62.  
  63. /* To be used inside a method for determining if the contents  are objects */
  64. #define CONTAINS_OBJECTS \
  65.   (ENCODING_IS_OBJECT([self contentType]))
  66.  
  67.  
  68. /* Error Handling */
  69.  
  70. #define RETURN_BY_CALLING_EXCEPTION_FUNCTION(FUNC) \
  71. return (*FUNC)(__builtin_apply_args())
  72.  
  73.  
  74. /* To be used inside a method for making sure the contents are objects.
  75.    typeof(DEFAULT_ERROR_RETURN) must be the same type as the method
  76.    returns. */
  77. #define CHECK_CONTAINS_OBJECTS_ERROR() \
  78. ({if (!(CONTAINS_OBJECTS)) \
  79. { \
  80.   [self error:"in %s, requires object contents", sel_get_name(_cmd)]; \
  81. }})
  82.  
  83. /* To be used inside a method whenever a particular element isn't found */
  84. #define ELEMENT_NOT_FOUND_ERROR(AN_ELEMENT) \
  85. ([self error:"in %s, element not found.", sel_get_name(_cmd)])
  86.  
  87. /* To be used inside a method whenever there is no element matching the 
  88.    needed criteria */
  89. #define NO_ELEMENT_FOUND_ERROR() \
  90. ([self error:"in %s, no element found.", sel_get_name(_cmd)])
  91.  
  92. #endif /* __CollectionPrivate_h_INCLUDE_GNU */
  93.